package com.ramms.eater.parser;

import org.w3c.dom.Element;

import com.ramms.eater.parser.base.AbstractParser;
import com.ramms.eater.parser.entity.Section;
import com.ramms.eater.util.Constants;

public class SectionParser extends AbstractParser<Section> {
	
	public SectionParser(String url) {
		super(url, Constants.TAG_SECTION);
	}
	
	public SectionParser() {
		super(Constants.URL_ELUNIVERSAL_API, Constants.TAG_SECTION);
	}

	@Override
	public Section getItem(Element e) {
		Section section = new Section();
		if(e.getAttribute(Constants.ATTR_NAME) != null)
			section.setName(e.getAttribute(Constants.ATTR_NAME));
		if(e.getAttribute(Constants.ATTR_TYPE) != null)
			section.setType(e.getAttribute(Constants.ATTR_TYPE));
		if(e.getAttribute(Constants.ATTR_LINK) != null)
			section.setLink(e.getAttribute(Constants.ATTR_LINK));
		if(e.getAttribute(Constants.ATTR_PUBDATE) != null)
			section.setPubDate(e.getAttribute(Constants.ATTR_PUBDATE));
		if(e.getAttribute(Constants.ATTR_IMAGE) != null)
			section.setImage(e.getAttribute(Constants.ATTR_IMAGE));
		if(e.getAttribute(Constants.ATTR_AD) != null)
			section.setAd(e.getAttribute(Constants.ATTR_AD));
		if(e.getAttribute(Constants.ATTR_ADIMG) != null)
			section.setAdImg(e.getAttribute(Constants.ATTR_ADIMG));
		if(e.getAttribute(Constants.ATTR_ADLINK) != null)
			section.setAdLink(e.getAttribute(Constants.ATTR_ADLINK));
		if(e.getAttribute(Constants.ATTR_COUNT) != null)
			section.setCount(e.getAttribute(Constants.ATTR_COUNT));
		if(e.getAttribute(Constants.ATTR_COUNTIPHONE) != null)
			section.setCountIphone(e.getAttribute(Constants.ATTR_COUNTIPHONE));
		return section;
	}
	
}
